package bhbt.service;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import bhbt.model.Admin;
import bhbt.model.Daili;
import bhbt.model.Member;
import bhbt.model.ParamWage;
import bhbt.model.TelVal;
import bhbt.model.WageCurrent;
import bhbt.model.log.LogChuangye;
import bhbt.model.log.LogEle;
import bhbt.model.log.LogKuang;
import bhbt.model.log.LogMoney;
import bhbt.model.log.LogOperAdmin;
import bhbt.model.log.LogShui;
import bhbt.model.log.LogStock;
import bhbt.service.core.BaseService;
import bhbt.service.log.LogChuangyeService;
import bhbt.service.log.LogEleService;
import bhbt.service.log.LogKuangService;
import bhbt.service.log.LogMoneyService;
import bhbt.service.log.LogOperAdminService;
import bhbt.service.log.LogShuiService;
import bhbt.service.log.LogStockService;
import bhbt.utils.ContextUtil;
import bhbt.utils.StringUtil;






 
@Service
public class MemberService extends BaseService {
	
	 
	@Resource
    private DailiService dailiService;
	@Resource
    private WageCurrentService wageCurrentService;
	
	@Resource
    private ParamWageService paramWageService;
	@Resource
    private LogChuangyeService logChuangyeService;
	@Resource
    private LogEleService logEleService;
	@Resource
    private LogMoneyService logMoneyService;
	@Resource
    private LogOperAdminService logOperAdminService;
	 
	@Resource
    private TelValService telValService;
	@Resource
    private LogShuiService logShuiService;
	@Resource
    private LogKuangService logKuangService;
	@Resource
    private LogStockService logStockService;
	
	
	
	/**
	 * 查询第一个激活的人
	 * @param loginName
	 * @return
	 */
	public Member executFirst() {
		 
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("accountActive", "T");
		param.put("pagination.orderBy"," id asc");  //排列
		List<Member> list = queryForList("select", param);
		 
		if(list.size()>0){
			return list.get(0);
		}else{
			return null;
		}
		 
		 
	}
	
	/**
	 * 查询第一个成为代理的人
	 * @param loginName
	 * @return
	 */
	public Member executFirstLevel() {
		 
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("accountActive", "T");
		param.put("where", "1=1 and level>0 ");
		param.put("pagination.orderBy"," id asc");  //排列
		
		List<Member> list = queryForList("select", param);
		 
		if(list.size()>0){
			return list.get(0);
		}else{
			return null;
		}
		 
		 
	}
	
	/**
	 * 根据登录名查询账号
	 * @param loginName
	 * @return
	 */
	public Member executMemberByLoginName(String loginName) {
		if(StringUtil.isNotBlank(loginName)) {
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("loginName", loginName);
			List<Member> members = queryForList("select", param);
			if (null != members && 0 < members.size()) {
				return members.get(0);
			}
		}
		return null;
	}
	
	public Member executMemberByTel(String tel) {
		if(StringUtil.isNotBlank(tel)) {
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("tel", tel);
			List<Member> members = queryForList("select", param);
			if (null != members && 0 < members.size()) {
				return members.get(0);
			}
		}
		return null;
	}
	
	
	     
	
	/**
	 * 注册
	 * @param member
	 */
	public void saveOne(Member member){
		
		
		 
		//新增会员
		this.saveOrUpdate(member);
		
		Integer memberId= member.getId();
		
		//新增工资表
		WageCurrent wageCurrent=new WageCurrent();		
		wageCurrent.setMemberId(memberId);		 //会员编号		
		wageCurrentService.saveOrUpdate(wageCurrent);
		
	 
		//更新对象信息
		Map<String, Object> mapMember = new HashMap<String, Object>();
		Integer wageCurrentId= wageCurrent.getId();
		 
		mapMember.put("id", memberId);
		mapMember.put("wageCurrentId", wageCurrentId);
		 
		this.update(mapMember);
		
	 
		
		
		
		
	}
	
	/***
	 * 删除
	 * @param id
	 */
	public void deleteOne(Integer id){
		Member one = this.getByKey(id);
		Integer wageCurrentId = one.getWageCurrentId();
		 
		//删除手机验证码
		TelVal telVal = telValService.executValByTel(one.getTel());
		telValService.delete(telVal);
		
		//删除工资表
		this.wageCurrentService.delete(wageCurrentId);
		
		
		//清除其父亲的对应的左右区
		Integer fatherId=one.getFatherId();
		if(one.getQu()!=null){
			
			if(fatherId!=null){
				Member father = this.getByKey(fatherId);
				
				Map mapFather = new HashMap();
				mapFather.put("id",father.getId());
	            
	            if(one.getQu()==1){
					 
	            	mapFather.put("diyUpdate","zuoId=null");
					 
				}
				if(one.getQu()==2){
					 
					mapFather.put("diyUpdate","youId=null");
				}
				
				this.update(mapFather);
			}
			
			
		}
		
		 
		//删除会员
		this.delete(id);
		
	}
	
	
	/**
	 * 激活
	 * @param id
	 */
	public void saveActive(Integer id,Integer activeId){
		Member one = this.getByKey(id);
		 
		Double payNum = one.getPayNum();
		if(one.getAccountActive().equals("F")){
			Map<String, Object> mapActiveOne = new HashMap<String, Object>();
			mapActiveOne.put("id", id);
			/******************  修改会员信息      **********************/
			mapActiveOne.put("accountActive", "T");
			
			mapActiveOne.put("activeId", activeId);
			mapActiveOne.put("activeDate", new Date());
			
			Daili daili = this.dailiService.getByKey(one.getDailiId());
			
			mapActiveOne.put("stock", daili.getGuNum()); 		//赠送原始股
		    this.update(mapActiveOne);
		    
		    LogStock logStock = new LogStock();
            logStock.setMemberId(id);
            logStock.setTitle("会员激活，获得原始股。");
            logStock.setState(88);
            logStock.setNum(daili.getGuNum()+0.0);
            logStock.setYu(daili.getGuNum()+0.0);
            logStockService.saveOrUpdate(logStock);
		    
		    
		    //给会员开矿
		   
			ParamWage paramWage1001 = this.paramWageService.getByKey(1001);
			double chanDayDouble = paramWage1001.getValue();
			Integer chanDay = (int)chanDayDouble;
			
			Random random = new Random(); 
			SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss"); 
			String kuangCodeNo="K"+formatter.format(new Date()) + random.nextInt(2) ;
			
			LogKuang logKuang = new LogKuang();
			logKuang.setMemberId(id);
			logKuang.setKuangCodeNo(kuangCodeNo);
			logKuang.setChanDay(chanDay);
			logKuang.setYuDay(chanDay);
			logKuang.setIsActive("T");
			logKuang.setActiveDate(new Date());
			this.logKuangService.saveOrUpdate(logKuang);
		    
		    
		    //扣激活人的现金币
		    one=this.getByKey(id);
		    
		    
			
		    if(one.getActiveId()!=null){
		    	
		    	Member active= this.getByKey(activeId);
		    	if(active!=null){
		    		Map mapActive = new HashMap();
		    		mapActive.put("id",activeId);
		    		mapActive.put("diyUpdate","money=money-"+payNum);
		            //更新余额 
		            this.update(mapActive);
		            
		            
		            Double yu = active.getMoney()-payNum;
		            
		            //新增记录
		            LogMoney logMoney = new LogMoney();
		            logMoney.setMemberId(activeId);
		            logMoney.setTitle("激活会员："+one.getLoginName());
		            logMoney.setState(88);
		            logMoney.setNum(-payNum);
		            logMoney.setYu(yu);
		            logMoneyService.saveOrUpdate(logMoney);
		    	}
		    	
		    }else{
		    	
		    	Admin admin = ContextUtil.getAdmin();
		    	
		    	LogOperAdmin log=new LogOperAdmin();
				log.setType(10);				//操作类别(10系统登录)
				log.setAdminId(admin.getId());
				log.setTitle("管理员激活");
				log.setCommitDate(new Date());
				log.setContext("激活会员："+one.getLoginName());
				logOperAdminService.saveOrUpdate(log); 
		    }
		    
		     
		   
		    /*****************  系统参数的激活人数**********************/
			  
			Map<String,Object> mapParamWage=new HashMap<String, Object>();
			// 今日激活、累计激活、今日激活、累计激活
			mapParamWage.put("where", "id = 2000 or id = 2002  ");//
			mapParamWage.put("diyUpdate", "value=value+"+1);
			paramWageService.update(mapParamWage);	
			
		 
			/*****************  系统参数的激活业绩**********************/			  
			mapParamWage=new HashMap<String, Object>();
			// 今日激活、累计激活、今日激活、累计激活
			mapParamWage.put("where", "id=2001 or id = 2003 ");//
			mapParamWage.put("diyUpdate", "value=value+"+payNum);
			paramWageService.update(mapParamWage);	
			
			
			
			
			
			
			
			/**************  给推荐人增加直推人数,直推业绩,直推奖 **************/
			Integer recommendId=one.getRecommendId();
			Member recommend = this.getByKey(recommendId);
			if(recommend!=null){
				Map<String, Object> mapRecommend = new HashMap<String, Object>();
				mapRecommend.put("id", recommendId);
				mapRecommend.put("diyUpdate", "recommendNum=RecommendNum+1,recommendYe=recommendYe+"+payNum);
				
				this.update(mapRecommend);
				
				//当天记录
				Integer wageCurrentId = recommend.getWageCurrentId();
				Map<String, Object> mapWageCurrent = new HashMap<String, Object>();
				mapWageCurrent.put("id", wageCurrentId);
				mapWageCurrent.put("diyUpdate", "recommendNum=recommendNum+1,recommendYe=recommendYe+"+payNum);
				
				wageCurrentService.update(mapWageCurrent);
				
				
				//直推奖
				recommend = this.getByKey(recommendId);
				Integer recommendDailiId =recommend.getDailiId();
				Daili recommendDaili = this.dailiService.getByKey(recommendDailiId);
				 
				
				Double wage1=recommendDaili.getTuiNum1()*0.01*payNum;
				
				
				this.saveCountWage1(recommend, one, wage1,1,payNum);
				 
			}
		
			/*******************************一条线增加业绩******************************/
			
			Integer reId=one.getRecommendId();
			Member re = this.getByKey(reId);
			//直推代数奖金
			Integer cengRe=1;
			  
			while(re!=null){		
				
				 
				Map<String, Object> mapRecommend = new HashMap<String, Object>();
				mapRecommend.put("id", reId);
				mapRecommend.put("diyUpdate", "recommendTotalNum=recommendTotalNum+1,recommendTotalYe=recommendTotalYe+"+payNum);
				this.update(mapRecommend);				 					
				System.out.println("进入*******");
				System.out.println("re*******:"+re.getLoginName());
				System.out.println("ceng*******:"+cengRe);
			  
				//当天记录
				Integer wageCurrentId = re.getWageCurrentId();
				Map<String, Object> mapWageCurrent = new HashMap<String, Object>();
				mapWageCurrent.put("id", wageCurrentId);
				mapWageCurrent.put("diyUpdate", "recommendTotalNum=recommendTotalNum+1,recommendTotalYe=recommendTotalYe+"+payNum);
				
				wageCurrentService.update(mapWageCurrent);
				
				
				 
				reId=re.getRecommendId();
				re = this.getByKey(reId);
				cengRe=cengRe+1;
				
			}
			 
			
		}
	}
	/**
	 * @功能  
	 */
	public void saveCountWage1(Member member,Member son,Double wage1,Integer activeKuangNum,Double wageActiveKuang){
		
		if(wage1>0){
			 
			String title="";
			//判断该会员是否停薪
			if(member.getStateWage().equals("F")){
				wage1=0d;
				title=title+"(工资已冻结)";
			}	
			 
			if(member.getAccountUse().equals("F")){
				wage1=0d;
				title=title+"(账户已冻结)";
			}	
			Daili daili = this.dailiService.getByKey(member.getDailiId());
			
			WageCurrent wageCurrent = this.wageCurrentService.getByKey(member.getWageCurrentId());
			if(wageCurrent.getWage1()+wage1>daili.getTuiFengNum()){
				wage1=daili.getTuiFengNum()-wageCurrent.getWage3();
				title=title+"(招商佣金已经封顶)";
			}
			
			
			
			
			//优化后：（由请求3次数据库优化为只请求一次）
			//招商佣金进入各个钱包百分数
			ParamWage paramWage1104 = this.paramWageService.getByKey(1104);		//进入现金币
			ParamWage paramWage1105 = this.paramWageService.getByKey(1105);		//进入复投
			ParamWage paramWage1106 = this.paramWageService.getByKey(1106);		//进入动物基金
			
			Map paraMap = new HashMap();
			paraMap.put("where", "1=1 and id in (1104,1105,1106) ");
			List<ParamWage> paramWageList = this.paramWageService.queryForList("select", paraMap);
			for (ParamWage paramWage : paramWageList) {
				if(1104 == paramWage.getId()){
					paramWage1104 = paramWage;
					continue;
				}
				else if(1105== paramWage.getId()){
					paramWage1105 = paramWage;
					continue;
				}
				else if(1106 == paramWage.getId()){
					paramWage1106 = paramWage;
					continue;
				}
				 
				  
			}
			
			Double money = wage1*paramWage1104.getValue()*0.01;
			Double chuangye = wage1*paramWage1105.getValue()*0.01;
			Double shui = wage1*paramWage1106.getValue()*0.01;
			
			
			
			Map<String, Object> paramMember = new HashMap<String, Object>();
			paramMember.put("id", member.getId());
			paramMember.put("diyUpdate"," wage1=wage1+"+wage1+",historyWage=HistoryWage+"+wage1+",money=money+"+money+",chuangye=chuangye+"+chuangye+",shui=shui+"+shui);
			this.update(paramMember);
			
			 
			
			Double yuMoney = member.getMoney()+money;
			Double yuChuangye = member.getChuangye()+chuangye;
			Double yuShui = member.getShui()+shui;
			
			
			
			//日志
			
			LogMoney log1=new LogMoney();
			log1.setMemberId(member.getId());										//所属会员
			log1.setTitle("招商佣金，开矿会员："+son.getLoginName()+"，开矿数："+activeKuangNum+"，开矿金额："+wageActiveKuang+"，招商佣金："+wage1+"，"+paramWage1104.getValue()+"%进入现金币。");		
			log1.setState(1);										//类型
			log1.setNum(money);											//数量
			log1.setTotalNum(money);
			log1.setIsFa("T");
			log1.setDongNum(0d);
			log1.setYu(yuMoney);
			log1.setCommitDate(new Date());	
			log1.setFaDate(new Date());		//时间
			logMoneyService.saveOrUpdate(log1);
			
			
			
			LogChuangye log2=new LogChuangye();
			log2.setMemberId(member.getId());										//所属会员
			log2.setTitle("招商佣金，开矿会员："+son.getLoginName()+"，开矿数："+activeKuangNum+"，开矿金额："+wageActiveKuang+"，招商佣金："+wage1+"，"+paramWage1105.getValue()+"%进入复投币。");		
			log2.setState(2);										//类型
			log2.setNum(chuangye);											//数量
			 
			log2.setYu(yuChuangye);
			log2.setCommitDate(new Date());	
			 
			logChuangyeService.saveOrUpdate(log2);
			
			
			
			
			LogShui log3=new LogShui();
			log3.setMemberId(member.getId());										//所属会员
			log3.setTitle("招商佣金，开矿会员："+son.getLoginName()+"，开矿数："+activeKuangNum+"，开矿金额："+wageActiveKuang+"，招商佣金："+wage1+"，"+paramWage1106.getValue()+"%进入动物基金。");		
			log3.setState(2);										//类型
			log3.setNum(shui);											//数量
			 
			log3.setYu(yuShui);
			log3.setCommitDate(new Date());	
			 
			logShuiService.saveOrUpdate(log3);
			 
			
			//改动当前工资
			Integer wageCurrentId=member.getWageCurrentId();
			Map<String, Object> paramWageCurrent = new HashMap<String, Object>();
			paramWageCurrent.put("id", wageCurrentId);
			paramWageCurrent.put("diyUpdate"," wage1=wage1+"+wage1+",wageNum=WageNum+"+wage1);
			this.wageCurrentService.update(paramWageCurrent);
			 
		}

	}
	/**
	 * @功能  
	 */
	public void saveCountWage2(Member member,Double wage2,Double kuangNum,Double wageKuang){
		
		if(wage2>0){
			 
			String title="";
			//判断该会员是否停薪
			if(member.getStateWage().equals("F")){
				wage2=0d;
				title=title+"(工资已冻结)";
			}	
			 
			if(member.getAccountUse().equals("F")){
				wage2=0d;
				title=title+"(账户已冻结)";
			}	
			
			Daili daili = this.dailiService.getByKey(member.getDailiId());
			System.out.println("daili.getChanKuangFengNum():"+daili.getChanKuangFengNum());
			if(wage2>=daili.getChanKuangFengNum()){
				wage2=daili.getChanKuangFengNum();
				title=title+"(每日产矿数已经封顶)";
			}
			System.out.println("wage2:"+wage2);
			
			//每日产矿进入各个钱包百分数
		
			//优化后：（由请求3次数据库优化为只请求一次）
			ParamWage paramWage1101 = this.paramWageService.getByKey(1101);		//进入原石
			ParamWage paramWage1102 = this.paramWageService.getByKey(1102);		//进入复投
			ParamWage paramWage1103 = this.paramWageService.getByKey(1103);		//进入动物基金
			
			Map paraMap = new HashMap();
			paraMap.put("where", "1=1 and id in (1101,1102,1103) ");
			List<ParamWage> paramWageList = this.paramWageService.queryForList("select", paraMap);
			for (ParamWage paramWage : paramWageList) {
				if(1101 == paramWage.getId()){
					paramWage1101 = paramWage;
					continue;
				}
				else if(1102== paramWage.getId()){
					paramWage1102 = paramWage;
					continue;
				}
				else if(1103 == paramWage.getId()){
					paramWage1103 = paramWage;
					continue;
				}
				 
				  
			}
			
			
			Double ele = wage2*paramWage1101.getValue()*0.01;
			Double chuangye = wage2*paramWage1102.getValue()*0.01;
			Double shui = wage2*paramWage1103.getValue()*0.01;
			
			
			
			Map<String, Object> paramMember = new HashMap<String, Object>();
			paramMember.put("id", member.getId());
			paramMember.put("diyUpdate"," wage2=wage2+"+wage2+",historyWage=HistoryWage+"+wage2+",ele=ele+"+ele+",chuangye=chuangye+"+chuangye+",shui=shui+"+shui);
			this.update(paramMember);
			 
			
			Double yuEle = member.getEle()+ele;
			Double yuChuangye = member.getChuangye()+chuangye;
			Double yuShui = member.getShui()+shui;
			
			
			
			//日志
		  
			
			LogEle log1=new LogEle();
			log1.setMemberId(member.getId());										//所属会员
			log1.setTitle("每日产矿，矿点数："+kuangNum+"，每个矿产矿数："+wageKuang+"，"+paramWage1101.getValue()+"%进入原石账户。"+title);				
			log1.setState(2);										//类型
			log1.setNum(ele);											//数量
			 
			log1.setYu(yuEle);
			log1.setCommitDate(new Date());	
			 
			logEleService.saveOrUpdate(log1);
			
			
			LogChuangye log2=new LogChuangye();
			log2.setMemberId(member.getId());										//所属会员
			log2.setTitle("每日产矿，矿点数："+kuangNum+"，每个矿产矿数："+wageKuang+"，"+paramWage1102.getValue()+"%进入复投币。"+title);				
			log2.setState(2);										//类型
			log2.setNum(chuangye);											//数量
			 
			log2.setYu(yuChuangye);
			log2.setCommitDate(new Date());	
			 
			logChuangyeService.saveOrUpdate(log2);
			
			
			LogShui log3=new LogShui();
			log3.setMemberId(member.getId());										//所属会员
			log3.setTitle("每日产矿，矿点数："+kuangNum+"，每个矿产矿数："+wageKuang+"，"+paramWage1103.getValue()+"%进入动物基金。"+title);				
			log3.setState(2);										//类型
			log3.setNum(shui);											//数量
			 
			log3.setYu(yuShui);
			log3.setCommitDate(new Date());	
			 
			logShuiService.saveOrUpdate(log3);
			 
			
			//改动当前工资
			Integer wageCurrentId=member.getWageCurrentId();
			Map<String, Object> paramWageCurrent = new HashMap<String, Object>();
			paramWageCurrent.put("id", wageCurrentId);
			paramWageCurrent.put("diyUpdate"," wage2=wage2+"+wage2+",wageNum=WageNum+"+wage2);
			this.wageCurrentService.update(paramWageCurrent);
			 
			 
		}
	

	}
	
	
	/**
	 * @功能  共享
	 */
	public void saveCountWage3(Member member,Member son,Double wage3,Double wageKuang){
		
		if(wage3>0){
			 
			String title="";
			//判断该会员是否停薪
			if(member.getStateWage().equals("F")){
				wage3=0d;
				title=title+"。(工资已冻结)";
			}	
			 
			if(member.getAccountUse().equals("F")){
				wage3=0d;
				title=title+"。(账户已冻结)";
			}	
			
			
			Daili daili = this.dailiService.getByKey(member.getDailiId());
			 
			WageCurrent wageCurrent = this.wageCurrentService.getByKey(member.getWageCurrentId());
			if(wageCurrent.getWage3()+wage3>daili.getGongFengNum()){
				wage3=daili.getGongFengNum()-wageCurrent.getWage3();
				title=title+"。(共享产值今日已封顶)";
			}
			
			 
			
			
			//每日产矿进入各个钱包百分数
			
			
			/********************* 持久化详细电子股 *********************/
			//优化后：（由请求6次数据库优化为只请求一次）
			ParamWage paramWage1107 = this.paramWageService.getByKey(1107);		//进入原石
			ParamWage paramWage1108 = this.paramWageService.getByKey(1108);		//进入复投
			ParamWage paramWage1109 = this.paramWageService.getByKey(1109);		//进入动物基金
			
			Map paraMap = new HashMap();
			paraMap.put("where", "1=1 and id in (1107,1108,1109) ");
			List<ParamWage> paramWageList = this.paramWageService.queryForList("select", paraMap);
			for (ParamWage paramWage : paramWageList) {
				if(1107 == paramWage.getId()){
					paramWage1107 = paramWage;
					continue;
				}
				else if(1108 == paramWage.getId()){
					paramWage1108 = paramWage;
					continue;
				}
				else if(1109 == paramWage.getId()){
					paramWage1109 = paramWage;
					continue;
				}
				 
				  
			}
			
			
			Double ele = wage3*paramWage1107.getValue()*0.01;
			Double chuangye = wage3*paramWage1108.getValue()*0.01;
			Double shui = wage3*paramWage1109.getValue()*0.01;
			
			
			
			Map<String, Object> paramMember = new HashMap<String, Object>();
			paramMember.put("id", member.getId());
			paramMember.put("diyUpdate"," wage3=wage3+"+wage3+",historyWage=HistoryWage+"+wage3+",ele=ele+"+ele+",chuangye=chuangye+"+chuangye+",shui=shui+"+shui);
			this.update(paramMember);
			
			member = this.getByKey(member.getId());
			
			
			Double yuEle = member.getEle()+ele;
			Double yuChuangye = member.getChuangye()+chuangye;
			Double yuShui = member.getShui()+shui;
			
			
			
			//日志
		  
			
			LogEle log1=new LogEle();
			log1.setMemberId(member.getId());										//所属会员
			log1.setTitle("共享产值，产矿会员："+son.getLoginName()+"，矿产数："+wageKuang+"，共享产值奖："+wage3+"，"+paramWage1107.getValue()+"%进入原石账户。"+title);				
			log1.setState(3);										//类型
			log1.setNum(ele);											//数量
			 
			log1.setYu(yuEle);
			log1.setCommitDate(new Date());	
			 
			logEleService.saveOrUpdate(log1);
			
			
			LogChuangye log2=new LogChuangye();
			log2.setMemberId(member.getId());										//所属会员
			log2.setTitle("共享产值，产矿会员："+son.getLoginName()+"，矿产数："+wageKuang+"，共享产值奖："+wage3+"，"+paramWage1108.getValue()+"%进入复投币。"+title);
							
			log2.setState(2);										//类型
			log2.setNum(chuangye);											//数量
			 
			log2.setYu(yuChuangye);
			log2.setCommitDate(new Date());	
			 
			logChuangyeService.saveOrUpdate(log2);
			
			
			LogShui log3=new LogShui();
			log3.setMemberId(member.getId());										//所属会员
			log2.setTitle("共享产值，产矿会员："+son.getLoginName()+"，矿产数："+wageKuang+"，共享产值奖："+wage3+"，"+paramWage1109.getValue()+"%进入动物基金。"+title);
			log3.setState(2);										//类型
			log3.setNum(shui);											//数量
			 
			log3.setYu(yuShui);
			log3.setCommitDate(new Date());	
			 
			logShuiService.saveOrUpdate(log3);
			
			//改动当前工资
			Integer wageCurrentId=member.getWageCurrentId();
			Map<String, Object> paramWageCurrent = new HashMap<String, Object>();
			paramWageCurrent.put("id", wageCurrentId);
			paramWageCurrent.put("diyUpdate"," wage3=wage3+"+wage3+",wageNum=WageNum+"+wage3);
			this.wageCurrentService.update(paramWageCurrent);
			 
			 
		}
	

	}
	
	
	
	
	 
	 
	 
	
	
	 
	 
}
